<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <component :is='currentView'></component>
        <button @click="handleChangView('A')">切换到A</button>
        <button @click="handleChangView('B')">切换到B</button>
        <button @click="handleChangView('C')">切换到C</button>
    </div>
    <script type="text/javaScript" charset="UTF-8" src="/JS文件/vue.js"></script>
    <script>
        var vm = new Vue({
            el:"#app",
            components:{
                comA:{
                    template:"<div>组件A</div>"
                },
                comB:{
                    template:"<div>组件B</div>"
                },
                comC:{
                    template:"<div>组件C</div>"
                }
            },
            data:{
                currentView:'comA'
            },
            methods:{
                handleChangView(component){
                    this.currentView = 'com'+component;
                }
            }
        })
    </script>
</body>
</html>